package com.tangmu.rabbits.adapter.home;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.tangmu.rabbits.R;
import com.tangmu.rabbits.adapter.MyBaseAdapter;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/4/28.
 */

public class HomeGridAdapter extends MyBaseAdapter<Integer> {


    public HomeGridAdapter(Context context, List<Integer> datasource) {
        super(context, datasource);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        GridViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.rv_item_home_activity_, parent, false);
            viewHolder = new GridViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (GridViewHolder) convertView.getTag();
        }
        //
        int res = datasource.get(position);
        viewHolder.ivName.setImageResource(res);
        return convertView;
    }

    public class GridViewHolder {

        @BindView(R.id.iv_activity_name)
        ImageView ivName;

        public GridViewHolder(View itemView) {
            ButterKnife.bind(this, itemView);
        }
    }

}
